<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<!-- RichFaces tag library declaration -->
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j" %>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich" %>
<h:form>
    <rich:dataTable value="#{geoPlacesDAO.flights}" id="flights_table"
                    onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
                    onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
                    cellpadding="0" cellspacing="0" headerClass="modalPanelHeader"
                    var="flight" rows="11" width="700" rowClasses="flightsTable" reRender="ds">

        <f:facet name="header">
            <rich:columnGroup>
                <rich:column colspan="7">
                    <h:outputText value="Скоро отправляются"/>
                </rich:column>
            </rich:columnGroup>
        </f:facet>

        <rich:column sortBy="#{flight.name}">
            <f:facet name="header">
                <h:outputText value="Номер рейса"/>
            </f:facet>
            <h:outputText value="#{flight.name}"/>
        </rich:column>

        <rich:column>
            <f:facet name="header">
                <h:outputText value="Место отправления"/>
            </f:facet>

            <h:outputText value="#{flight.cityFrom}">

            </h:outputText>
        </rich:column>

        <rich:column>
            <f:facet name="header">
                <h:outputText value="Место назначения"/>
            </f:facet>
            <h:outputText value="#{flight.cityTo}">
            </h:outputText>
        </rich:column>

        <rich:column sortBy="#{flight.departure}">
            <f:facet name="header">
                <h:outputText value="Время вылета"/>
            </f:facet>
            <h:outputText value="#{flight.departure}">
                <f:convertDateTime type="both" pattern="dd.MM.yyyy hh:mm"/>
            </h:outputText>
        </rich:column>

        <rich:column sortBy="#{flight.arrival}">
            <f:facet name="header">
                <h:outputText value="Время прибытия"/>
            </f:facet>
            <h:outputText value="#{flight.arrival}">
                <f:convertDateTime type="both" pattern="dd.MM.yyyy hh:mm"/>
            </h:outputText>
        </rich:column>

        <rich:column>
            <f:facet name="header">
                <h:outputText value="Перевозчик"/>
            </f:facet>
            <h:outputText value="#{flight.companyId}"/>
        </rich:column>
        <rich:column>
            <f:facet name="header">
            </f:facet>

            <h:graphicImage value="/images/buy.gif" id="link" style="cursor:pointer">
                <rich:componentControl for="panel" attachTo="link" operation="show" event="onclick"/>
            </h:graphicImage>
            <rich:modalPanel id="panel" width="350" height="150">
                <f:facet name="header">
                    <h:panelGroup>
                        <h:outputText value="Выбор билетов"/>
                    </h:panelGroup>
                </f:facet>
                <f:facet name="controls">
                    <h:panelGroup>
                        <h:graphicImage value="/images/close.png" style="cursor:pointer" id="hidelink"/>
                        <rich:componentControl for="panel" attachTo="hidelink" operation="hide" event="onclick"/>
                    </h:panelGroup>
                </f:facet>
                <h:panelGrid columns="2">
                    <h:outputText value="Заказ билета на рейс"/>
                    <h:outputText value="#{flight.name}"/>

                    <h:outputText value="#{flight.cityFrom} → #{flight.cityTo}">
                        <f:convertDateTime type="both" pattern="dd.MM.yyyy hh:mm"/>
                    </h:outputText>
                    <h:outputText value="вылет: #{flight.departure}"/>

                    <h:outputText value="Билетов бизнес-класса: "/>
                    <rich:inputNumberSpinner value="0" maxValue="#{flight.bussinessPlaces}"
                                             disabled="#{flight.bussinessPlaces <= 0}"/>

                    <h:outputText value="Билетов эконом-класса: "/>
                    <rich:inputNumberSpinner value="0" maxValue="#{flight.economPlaces}"
                                             disabled="#{flight.economPlaces <= 0}"/>


                    <a4j:commandButton value="Спасибо, в другой раз"/>
                    <a4j:commandButton value="Оформить бронь"/>
                </h:panelGrid>

            </rich:modalPanel>
        </rich:column>
        <f:facet name="footer">
            <rich:datascroller id="ds"/>
        </f:facet>
    </rich:dataTable>
</h:form>